package com.yzq.model.dto.picture;

import com.yzq.model.entity.Picture;
import com.yzq.model.vo.PictureVO;
import lombok.Data;

@Data
public class PictureAnalysisResult {
    /**
     * 图片地址
     */
    private String url;

    /**
     * 图片名称
     */
    private String picName;

    /**
     * 文件体积
     */
    private Long picSize;

    /**
     * 图片宽度
     */
    private int picWidth;

    /**
     * 图片高度
     */
    private int picHeight;

    /**
     * 图片宽高比
     */
    private Double picScale;

    /**
     * 图片格式
     */
    private String picFormat;

    /**
     * 缩略图 url
     */
    private String thumbnailUrl;

    /**
     * 转PictureVO 对象
     */
    public static PictureVO toPictureVO(PictureAnalysisResult pictureAnalysisResult) {
        PictureVO pictureVO = new PictureVO();
        pictureVO.setUrl(pictureAnalysisResult.getUrl());
        pictureVO.setName(pictureAnalysisResult.getPicName());
        pictureVO.setPicSize(pictureAnalysisResult.getPicSize());
        pictureVO.setPicWidth(pictureAnalysisResult.getPicWidth());
        pictureVO.setPicHeight(pictureAnalysisResult.getPicHeight());
        pictureVO.setPicScale(pictureAnalysisResult.getPicScale());
        pictureVO.setPicFormat(pictureAnalysisResult.getPicFormat());
        pictureVO.setThumbnailUrl(pictureAnalysisResult.getThumbnailUrl());
        return pictureVO;
    }

    /**
     * 转 PictureAnalysisResult 对象
     */
    public static PictureAnalysisResult fromPictureVO(PictureVO pictureVO) {
        PictureAnalysisResult pictureAnalysisResult = new PictureAnalysisResult();
        pictureAnalysisResult.setUrl(pictureVO.getUrl());
        pictureAnalysisResult.setPicName(pictureVO.getName());
        pictureAnalysisResult.setPicSize(pictureVO.getPicSize());
        pictureAnalysisResult.setPicWidth(pictureVO.getPicWidth());
        pictureAnalysisResult.setPicHeight(pictureVO.getPicHeight());
        pictureAnalysisResult.setPicScale(pictureVO.getPicScale());
        pictureAnalysisResult.setPicFormat(pictureVO.getPicFormat());
        pictureAnalysisResult.setThumbnailUrl(pictureVO.getThumbnailUrl());
        return pictureAnalysisResult;
    }

    /**
     * 转 Picture 对象
     */
    public static Picture toPicture(PictureAnalysisResult pictureAnalysisResult) {
        Picture picture = new Picture();
        picture.setUrl(pictureAnalysisResult.getUrl());
        picture.setName(pictureAnalysisResult.getPicName());
        picture.setPicSize(pictureAnalysisResult.getPicSize());
        picture.setPicWidth(pictureAnalysisResult.getPicWidth());
        picture.setPicHeight(pictureAnalysisResult.getPicHeight());
        picture.setPicScale(pictureAnalysisResult.getPicScale());
        picture.setPicFormat(pictureAnalysisResult.getPicFormat());
        picture.setThumbnailUrl(pictureAnalysisResult.getThumbnailUrl());
        return picture;
    }
}
